package database

import (
	_ "embed"
	"gitee.com/zaper/private-logger"
	"gitee.com/zaper/service-center-client/util"
	"sync"
)

type SqlInfo struct {
	SqlName string
	Sql     string
}

var (
	SqlInfos = make(map[string]string)
	sqlSW    sync.RWMutex
)

func AddSqlInfos(sqlInfoStr string) {
	sqlSW.Lock()
	defer sqlSW.Unlock()
	p, err := util.ParseStringToProperties(sqlInfoStr)
	if err != nil {
		logger.Info("Initialize sqlInfoStr is fail, err is %s", err)
	}
	SqlInfos = p.Data
	logger.Infof("all sqls is %s", SqlInfos)
}

func GetSqlInfo(sqlName string) string {
	return SqlInfos[sqlName]
}
